package com.hj.tools.bootstrap;

import java.util.LinkedList;
import java.util.List;

/**
 * 启动项管理
 * @author HJ
 */
public class BootstrapManager {
	private BootstrapManager(){}
	private static List<Config> bootList = new LinkedList<Config>();
	
	public synchronized static void addConfig(Config cfg){
		bootList.add(cfg);
	}
	
	public static ConfigMsg start(){
		ConfigMsg cfgMsg = null;
		for (Config cfg : bootList) {
			cfgMsg = cfg.Processing(cfg);
			if (!cfgMsg.getStatus()) {
				break;
			}
		}
		return cfgMsg;
	}
	
	
}

class ConfigMsg{
	boolean status = false;
	public void setStatus(boolean status) {
		this.status = status;
	}
	public boolean getStatus() {
		return status;
	}
	
	String msg;
	public void setMsg(String msg) {
		this.msg = msg;
	}
	public String getMsg() {
		return msg;
	}
}

/**
 * 执行BootstrapManager.addConfig()
 * 实现Config接口
 * ----------------------
 * @author HJ
 */
interface Config{
	ConfigMsg Processing(Config cfg);
}
